﻿@model Coslen.TahorCRM.Domain.Entities.ViewModels.Editing.GroupEditViewModel

@Html.HiddenFor(model => model.Group.GroupId)
	
<div class="display-row">
    <div class="display-label">
        @Html.LabelFor(model => model.Group.Name)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Group.Name)
    </div>
</div>

<div class="display-row">
    <div class="display-label">
        @Html.LabelFor(model => model.Group.GroupTypeId)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Group.GroupTypeId)
    </div>
</div>


<div class="display-row">
    <div class="display-label">
		@Html.LabelFor(model => model.Group.CreatedAt)
	</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Group.CreatedAt)
    </div>
</div>

<div class="display-row">
    <div class="display-label">
		@Html.LabelFor(model => model.Group.UpdatedAt)
	</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Group.UpdatedAt)
    </div>
</div>

<div class="display-row">
    <div class="display-label">
        @Html.LabelFor(model => model.Group.DeletedAt)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Group.DeletedAt)
    </div>
</div>

<div class="display-row">
    <div class="display-label">
        Members
    </div>
    <div class="display-field">
        @Html.ActionLink("Edit Member List", "EditList", "GroupContact", new { groupId = Model.Group.GroupId }, null)
        @{
            var numberOfColumns = 3;
            var numberOfContacts = Model.Group.GroupContacts.Count;
            int numberInEachColumn = numberOfContacts/numberOfColumns;
            <table>
                <tr>
                    <td>
                        <ul>
                            @for (int index = 0; index < numberOfContacts; index = index + 3)
                            {
                                var groupContact = Model.Group.GroupContacts.ToArray()[index];
                                <li>@groupContact.Contact.LastName, @groupContact.Contact.FirstName</li>
                            }
                        </ul>
                    </td>
                    <td>
                        <ul>
                            @for (int index = 1; index < numberOfContacts; index = index + 3)
                            {
                                var groupContact = Model.Group.GroupContacts.ToArray()[index];
                                <li>@groupContact.Contact.LastName, @groupContact.Contact.FirstName</li>
                            }
                        </ul>
                    </td>
                    <td>
                        <ul>
                            @for (int index = 2; index < numberOfContacts; index = index + 3)
                            {
                                var groupContact = Model.Group.GroupContacts.ToArray()[index];
                                <li>@groupContact.Contact.LastName, @groupContact.Contact.FirstName</li>
                            }
                        </ul>
                        
                    </td>
                </tr>
            </table>
        }
    </div>
</div>


